#ifndef _WORLD_SOCKET_HPP
#define _WORLD_SOCKET_HPP
#include "MessageBuffer.hpp"
#include "Socket.hpp"
#include "WorldPacket.hpp"
#include <memory>
#include <mutex>
#include "LockQueue.hpp"
struct HeaderPacket
{
  uint32_t _size;
  uint16_t _opcode;
  // 可以加tag校验数据
  bool IsVaildSize() { return _size < 0x10000; } // 64K
};

class WorldSocket : public Socket<WorldSocket>
{
public:
  WorldSocket(boost::asio::ip::tcp::socket&& sc);
public:
  bool Update() override;
  bool HandleRead() override;
  void SendPacket(WorldPacket&& packet);
private:
  void AddRecvPacket(std::shared_ptr<WorldPacket>&& packet);
private:
    LockedQueue<std::shared_ptr<WorldPacket>> _recvPacketQueue;
    LockedQueue<std::shared_ptr<WorldPacket>> _writePacketQueue;
    MessageBuffer _headerMessage;
    MessageBuffer _dataMessage;
};

#endif